package com.im.app.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.im.app.model.User;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface IUserMapper extends BaseMapper<User> {

    @Select("select * from user where kefu_id=#{kefuId} and last_login_ip=#{ip} and TIMESTAMPDIFF(MINUTE, last_login_time, NOW()) <= 20 limit 1")
    User getUserByKefuIdAndIp(@Param("kefuId") String kefuId, @Param("ip") String ip);

    @Select("select * from user where kefu_id=#{kefuId} and device_id=#{deviceId} limit 1")
    User getUserByDeviceId(@Param("kefuId") String kefuId, @Param("deviceId") String deviceId);

    @Update(value = "update user set status = #{status} where user_id=#{userId}")
    int doBlackByUserIdAndIp(@Param("userId") String userId, @Param("status")int status);

    int getTodayVisitor(String userId);

//    List<Map<String,String>> getSumVisitor(String userId);
    List<User> getUserByKefuId(String kefuId, String date);


}
